call StoreCurrentYamState /**** Store current YAM state ****/
address COMMAND 'List '||IncomingPath||' LFORMAT %p%n >T:TempFileList' /**** List the Incoming Folder's messages to temporary file using real filenames ****/
call open('FileList','T:TempFileList') /**** Build a New Message file list ****/
if left(subword(statef(MessageName),8,1),1) ~= 'N' then iterate
call writeln('NewMessageList',MessageName)
TotalNewMessages = TotalNewMessages + 1
end
call close('NewMessageList')
call close('FileList')
if TotalNewMessages < 1 then call GoodBye
call StatusRequesterBuild /**** Open the GUI ****/
call open('NewMessageList','T:TempNewMessageList') /**** Start the scan, file by file ****/
do MessagesSofar = 1 to TotalNewMessages
call ToPipe('tick 0') /**** Check if User wants to abort by either hitting Abort or window close gadgets ****/
res = readln('StatusGUI')
parse var res res1 res2 .
if res1 = 'close' | res1 = 'gadget' & res2 = QUITID then call GoodBye
AdvertStripped = 0
CurrentFileName = readln('NewMessageList')
call open('CurrentMessage',CurrentFileName)
call open('WriteFile','T:TempFileOut','write')
/**** Read and Write message lines until To: Header is reached ****/
do until eof('CurrentMessage') | upper(left(CurrentLine,3)) = 'TO:' /* Do uppercase-only checking due to incidences where To: header can be to: or TO: or even tO: :^) */
CurrentLine = readln('CurrentMessage')
call writeln('WriteFile',CurrentLine)
end
/**** Iterate if To: does not contain "yahoogroups" ****/
if pos('YAHOOGROUPS',upper(CurrentLine)) = 0 then do /* Do uppercase-only checking due to incidences where To: field contains a mixed case address */
/* ======== End Main Routine =============================================== */
FindIncoming:
userinfo stem userinfo.
SettingsDirectory = userinfo.maildir
if right(SettingsDirectory,1) ~= '/' & right(SettingsDirectory,1) ~= ':' then SettingsDirectory = SettingsDirectory||'/' /**** Add trailing '/' in path name if it is not present, but only if trailing char is not a ':' ****/
IncomingCount = -1
if open('FolderList',SettingsDirectory||'.folders') then do
call readln('FolderList') /**** skip first line in .folders file ****/
do while ~eof('FolderList')
IncomingCount = IncomingCount + 1
call readln('FolderList')
FolderDirectory = readln('FolderList')
if FolderDirectory = "" then break
if left(FolderDirectory,1) = "@" then iterate
if index(FolderDirectory,":") = 0 then FolderDirectory = SettingsDirectory||FolderDirectory /**** If the full pathname (ie. root device) is not present in .folders file, add it. I hope this satisfies all possibilities! ****/
if open('FolderConfigFile',FolderDirectory||'/.fconfig') then do
ToPipe: /**** this routine does error checking on lines written to pipe ****/
parse arg out /**** get line to output ****/
call writeln('StatusGUI',out) /**** write to the pipe ****/
ResultText = readln('StatusGUI') /**** get response and parse it ****/
parse var ResultText ResultText1 ResultText2 .
if ResultText1 = 'ok' then return(ResultText2) /**** if all is ok return the second part of the response (usualy the GID) ****/
say 'error from: 'out /**** something went wrong, we notify the user then exit, show problem line and response (reponse may be just a blank line) ****/